/*
 * test-client.cpp
 *
 *  Created on: 2021年2月21日
 *      Author: Administrator
 */

#include "client_socket.h"
#include <logger.h>
#include <iostream>
#include <boost/bind/bind.hpp>
#include <boost/thread/thread.hpp>

int main(int argc, char **argv)
{
	logger_init(eTrace, true);

	boost::asio::io_service io_svc;
	client_socket client(io_svc);
	client.set_magic(0xAFFA);
	client.set_ver(0x02);
	client.set_reconnect(3);
	client.connect("localhost", "6000");

	boost::thread t(
			boost::bind((io_svr_run_no_arg) &boost::asio::io_service::run,
					&io_svc));

    char line[512+1];
    sck_pkg_t pkg;
    while (std::cin.getline(line, 512))
    {
    	client.sck_pkg_new(&pkg, 0xDF01, 0, line, strlen(line));
    	client.send_pkg(pkg);
    }

    client.close();
    t.join();
	return 0;
}



